<template>
	<view>
		<button @click="zhiPay">支付宝付款</button>
		<button @click="weiPay">微信付款</button>
	</view>
</template>

<script>
	export default {
		data() {
			return {
				
			}
		},
		methods: {
			zhiPay (){
				uni.getProvider({
				    service: 'payment',
				    success: function (res) {
				        console.log(res.provider)
				        if (~res.provider.indexOf('alipay')) {
				          uni.requestPayment({
				              provider: "10",
				              orderInfo: 'orderInfo', //微信、支付宝订单数据
				              success: function (res) {
				                  console.log('success:' + JSON.stringify(res));
				              },
				              fail: function (err) {
				                  console.log('fail:' + JSON.stringify(err));
				              }
				          }); 
				        }
				    }
				});
			},
			weiPay (){
				uni.getProvider({
				    service: 'payment',
				    success: function (res) {
				        console.log(res.provider)
				        if (~res.provider.indexOf('wxpay')) {
				            uni.requestPayment({
				                provider: 'wxpay',
				                orderInfo:"20", //微信、支付宝订单数据
				                success: function (res) {
				                    console.log('success:' + JSON.stringify(res));
				                },
				                fail: function (err) {
				                    console.log('fail:' + JSON.stringify(err));
				                }
				            });
				        }
				    }
				});
			}
		}
	}
</script>

<style>

</style>
